package JavaSE.CODE.javaCollection;

import java.util.Comparator;
import java.util.TreeMap;

public class TreeMapDemo {
    public static void main(String[] args) {
        TreeMap<Student,String> treeMap = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge()-o2.getAge();
            }
        });

        Student s1 = new Student("孙文强",10);
        Student s2 = new Student("李玉峰",11);
        Student s3 = new Student("张馨予",12);

        treeMap.put(s1,"a");
        treeMap.put(s2,"b");
        treeMap.put(s3,"c");

        System.out.println(treeMap);

    }
}
